<?php
class MenuSystem{
		function MenuSystem(){
			//
		}
		function getarray($result){
			return @mysql_fetch_array($result);
		}
		//显示所有系统名称;
		function Systemlist($rs){
			if(!empty($rs))
			{
				echo "<table width=\"80%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\" class=\"TableLine\">
				<tr>
				  <td colspan=\"7\" height=\"10\"></td>
				</tr>";
				while($row=$this->getarray($rs))
				{
				echo "<tr>
					<td  class=\"TdLineBG\"><div align=\"right\">系统名称：</div></td>
					<td  class=\"TdLine\" align=\"left\"><label>$row[1]</label></td>
					<td  class=\"TdLineBG\"><div align=\"right\">系统表名：</div></td>
					<td  class=\"TdLine\"><label>$row[3]</label></td>
					<td  class=\"TdLineBG\"><div align=\"right\">系统路径：</div></td>
					<td  class=\"TdLine\"><label>$row[2]</label></td>
					<td  class=\"TdLine\">";
					$isdel=trim($row[4]);
					if(intval($isdel)==0)
					{
						echo "<a href=\"".$_SERVER['PHP_SELF']."?act=del&id=$row[0]\" onclick=\"return confirm('你确认要删除吗？,删除后不能恢复！！')\" class=\"Link12\">删除</a>";
					}
					else
					{
						echo "系统表";
					}
					echo "</td>
					</tr>";
				}
				echo "</table>";
			}
		}
		/**
		 * 把数据返回 二维数组
		 */
		function GetDatalist($result){
			$j=0;
			$fieldscount=@mysql_num_fields($result);
			while($row=@mysql_fetch_array($result))
			{
				for($i=0;$i<$fieldscount;$i++)
				{
					$Datalist[$j][$i]=$row[$i];
				}
				$j++;
			}
			return $Datalist;
		}

		function getClasslist($type=0){
			$db=new mysql();
			$rest=$db->query("select * from classsys where classsys2=$type order by classsys3 asc");
			while($listdate=@$db->getarray($rest))
			{
				$listarr.="<option value='".$listdate[0]."'>".$listdate[1]."</option>";
			}
			echo $listarr;
		}

		function MenuClassSyslist(){
			$db=new mysql();
			$rest=$db->query("select * from menusys where menusys8='classsys' Order by menusys0 desc");
			$listarr='';
			while($listdate=@$db->getarray($rest))
			{
				$listarr.="<option value='".$listdate[0]."'>".$listdate[1]."</option>";
			}
			echo $listarr;
		}




		function dropdownlist($fieldtype=0){
	          echo "<option value=\"1\">文本框</option>
	          <option value=\"2\">下拉框</option>
	          <option value=\"3\">单选框</option>
			  <option value=\"4\">复选框</option>
			  <option value=\"5\">文本域</option>
	          <option value=\"6\">图片上传框</option>
			  <option value=\"16\">文件上传框</option>
			  <option value=\"17\">大文件上传</option>
			  <option value=\"7\">编辑器</option>
			  <option value=\"8\">栏目ID</option>
			  <option value=\"9\">审核ID</option>
			  <option value=\"10\">日期框</option>
			  <option value=\"15\">系统时间</option>
			  <option value=\"11\">会员ID</option>
			  <option value=\"12\">图片集上传</option>
			  <option value=\"13\">Ajax验证</option>
			  <option value=\"14\">图片集上传1</option>";
		}

		/**
		 * 获取表名
		 */
		function GetTableName($MenuID){
                            static $isrun = array();
                            if(!isset($isrun['GetTableName'.$MenuID])){
			if(is_numeric($MenuID)){
				$db=new mysql();
				$row=$db->getoners("select menusys8 from menusys where menusys0={$MenuID} limit 1");
				$isrun['GetTableName'.$MenuID] = $row[0];
			}
                            }
                            return $isrun['GetTableName'.$MenuID];
		}

		/**
		 * 字段类型
		 */
		function getfieldtype($type=""){
			if(empty($type))
			{
				return "错误码的数据类型";
			}
			$type=strtolower($type);
			switch ($type) {
			   case "int":
				   return "数字";
			   case "string":
				   return "字符";
				   break;
			   case "blob":
				   return "备注";
				   break;
			   case "datetime":
				   return "时间";
				   break;
				case "date":
				   return "时间(年-月-日)";
				   break;
				case "time":
				   return "时间(时:分:秒)";
				   break;
				case "real":
					return "浮点";
					break;

				default:
					return	$type;
			}


		}
		/**
		 *  返回栏目配置字段的值
		 */
		 function GetMenuSysFormConfig($MenuID){
		 	if(is_numeric($MenuID))
		 	{
				$db=new mysql();
				$row=$db->getoners("select menusys4 from menusys where menusys0={$MenuID} limit 1");
				return $row[0];
		 	}
		 }
		 
		 /**
		  *  返回栏目的字段序号，也就是栏目ID在哪一个字段。
		  */
		 function GetFormConfigMenuIDFieldID($MenuID){
		 	$getfromconfig=$this->GetMenuSysFormConfig($MenuID);
			$getfromconfigarr=explode(",",$getfromconfig);
		 	for($i=0;$i<count($getfromconfigarr);$i++){
				$fromconfiglist=explode("|",$getfromconfigarr[$i]);
				if(isset($fromconfiglist[1])){
					if(strval($fromconfiglist[1])=="8"){
						return $i;
						break;
					}
				}
			}
		 }
		 
		 /**
		  *  返回栏目的字段序号，也就是审核ID在哪一个字段。
		  */
		 function GetFormConfigShenHeIDFieldID($MenuID){
		 	$getfromconfig=$this->GetMenuSysFormConfig($MenuID);
			$getfromconfigarr=explode(",",$getfromconfig);
		 	for($i=0;$i<count($getfromconfigarr);$i++){
				$fromconfiglist=explode("|",$getfromconfigarr[$i]);
				if($fromconfiglist[1]=="9"){
					return $i;
					break;
				}
			}
			return false;
		 }
		 
		 /**
		  * 返回MenuSys表的数据
		  */
		 function GetMenuSysField($MenuID,$Fields=""){
                            static $isrun = array();
                            $key = $MenuID.'-'.$Fields;
                            if(!isset($isrun[$key])){
                                if(is_numeric($MenuID)) {
                                        $db=new mysql();
                                        if(empty($Fields)){
                                                $isrun[$key] = $db->getoners("select * from menusys where menusys0={$MenuID}  limit 1");
                                        }
                                        else{
                                                $row=$db->getoners("select menusys{$Fields} from menusys where menusys0={$MenuID} limit 1");
                                                $isrun[$key] = $row[0];
                                        }
                                }
                            }
                            return $isrun[$key];
		 }
		 
		 /**
		  * 获取列表配置字段的值
		  */
		 function GetMenuSysFromListConfig($MenuID){
		 	if(is_numeric($MenuID))
		 	{
				$db=new mysql();
				$row=$db->getoners("select menusys5 from menusys where menusys0={$MenuID} limit 1");
				return $row[0];
		 	}
		 }
}
$System=new MenuSystem();

class HtmlInclude
{
	public $cssroot;
	function __construct()
	{
		//
		global $wwwroots,$adminroots;
		$this->cssroot=$wwwroots.'/'.$adminroots;
	}
	/**
	 * 输入html开始
	 */
	function includetop($title="系统管理",$addbody="")
	{
		echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<title>$title</title>\n<link href=\"".$this->cssroot."/Css.css\" rel=\"stylesheet\" type=\"text/css\"><link rel=\"stylesheet\" type=\"text/css\" href=\"../ueditor/themes/default/ueditor.css\"/>
<script charset=\"utf-8\" src=\"../editor/kindeditor-min.js\"></script>\n
<script type=\"text/javascript\" src=\"../lzsswfupload/jquery.js\"></script>
<script language=\"javascript\" src=\"../lzsswfupload/swfupload.js\"></script>
<script language=\"javascript\" src=\"../lzsswfupload/lzsswfupload.js\"></script>
<style type=\"text/css\">
.swfuplaodimg{ margin:0px; padding:0px; border:red solid 1px;}
.swfuploadimg li{ width:200px;position:relative;height:200px; margin:0px; margin-right:20px; float:left; list-style:none;}
.swfuploadimg li img{ width:200px; border:#CCC solid 1px; height:150px;}
.swfuploadimg li span{ display:block; width:100%;}
.swfuploadimg li div{ position:absolute; filter: alpha(opacity=50); -moz-opacity: 0.50; opacity: 0.50; top:0px; background:#616975; right:0px; height:24px; line-height:24px; text-align:center; font-size:12px;width:35px;}
.swfuploadimg li div a{ color:#ffffff;}
.swfuploadimg li div:hover{ filter: alpha(opacity=100); -moz-opacity: 1; opacity: 1;transition:.5s;-moz-transition:.5s;-webkit-transition:.5s;-o-transition:.5s;}
.swfuploadimg li span input{ width:188px;}
.swfuploadfilebox{ width:500px; display:none}
.swfuploadfilelist{margin:0px; padding:0px; width:500px; }
.swfuploadfilelist li{ list-style:none; font-size:12px; margin-top:-1px; border:#EEEEEE solid 1px;}
.swfuploadfilelist li .swfuploadjingdutiao{border-radius:6px; float:left; display:block; width:100px; background:#BFBFBF; border:#959595 solid 1px; height:12px; overflow:hidden;}
.swfuploadfilelist li .swfuploadjingdutiao div{border-radius:6px; width:0px;  height:12px; background:#4F7AFD; overflow:hidden;}
.a-upload {
    position: relative;
	cursor: pointer;
	overflow:hidden;
	  border-color: #f0ad4e;
	  color:#FFFFFF;
	    padding: 5px 8px;

	  background-color: #f0ad4e;
	display: inline-block;
	text-align: center;
	white-space: nowrap;
	  vertical-align: middle;
	  background-image: none;
	  border: 1px solid transparent;
		border-radius: 3px;
		  cursor: pointer;
		  user-select: none;
}
.a-upload  input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
	width:100%;
	height:1px;
    filter: alpha(opacity=0);
    cursor: pointer;
}
</style></head>\n\n<body {$addbody}>
";
	}
	/**
	 * 输入html结束
	 */
	function includeend()
	{
		echo "</body>\n</html>";
	}

	function includemenusystemadd()
	{
		echo "<br>
		<table width=\"80%\"  border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:#B14404 solid 1px;\" class=\"YKTtable\">
		  <tr>
			<td height=\"25\" style=\"background-image:url(../../iamges/THBG.jpg); background-repeat:repeat-x; height:25px; padding-left:10px;\" valign=\"middle\"><span class=\"Font12W\">添加新系统 </span><br></td>
		  </tr>
		  <tr>
			<td style=\"height:5px; overflow:hidden; background-color:#B14404\"></td>
		  </tr>
		  <tr class=\"YKTtd\">
			<td>
		<form id=\"AddTable\" name=\"AddTable\" method=\"post\" action=\"\">
		<table width=\"95%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\" class=\"TableLine\" id=\"AddTableBox\">
			<tr>
			  <td colspan=\"3\" height=\"10\"></td>
			</tr>
			<tr>
			  <td width=\"20%\"  class=\"TdLineBG\"><div align=\"right\">系统名称：</div></td>
			  <td width=\"70%\"  class=\"TdLine\"><label>
				<input name=\"SysName\" type=\"text\"  class=\"InputNone\" id=\"SysName\" value=\"自助系统的名称\" onfocus=\"if(this.value==this.defaultValue){this.value=''}\" onblur=\"if(this.value==''){this.value=this.defaultValue}\" size=\"50\"/> *添加后不能修改
			  </label></td>
			  <td width=\"10%\"  class=\"TdLine\">&nbsp;</td>
			</tr>
			<tr>
			  <td  class=\"TdLineBG\"><div align=\"right\">系统表名：</div></td>
			  <td  class=\"TdLine\"><label>
			  sen_
			  <input name=\"SysTableName\" type=\"text\" id=\"SysTableName\" value=\"\" size=\"5\" maxlength=\"15\"/>
			  </label></td>
			  <td  class=\"TdLine\">&nbsp;</td>
			</tr>
			<tr>
			  <td height=\"30\">&nbsp;</td>
			  <td valign=\"bottom\"><input type=\"submit\" name=\"Submit\" onclick=\"return yzadd()\"  value=\" 确定 \" />
&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"".$_SERVER['HTTP_REFERER']."\">返回上一页</a></td>
			  <td>&nbsp;</td>
			</tr>
		  </table>
		</form>
		</td>
		  </tr>
		</table>
		<script type=\"text/javascript\">
		function $(getid){return document.getElementById(getid);}
		function yzadd()
		{
			if($(\"SysName\").value==\"\"||$(\"SysName\").value==\"自助系统的名称\")
			{
				alert(\"系统名称,不能为空！！\");
				$(\"SysName\").value=\"\";
				$(\"SysName\").select();
				return false;
			}
			if($(\"SysTableName\").value==\"\")
			{
				alert(\"系统表名,不能为空！！\");
				$(\"SysTableName\").focus();
				return false;
			}
		}
		</script><br><br><br>";
	}
	/**
	 * 添加栏目
	 */
	function addMenu($MenuID=false)
	{
		$db=new mysql();
		
		if($MenuID==false)
		{
			echo "当前位置：添加一级栏目&nbsp;>&nbsp;添加栏目
				<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				  <table width=\"95%\" border=\"0\" align=\"center\">
					<tr>
					  <td width=\"35%\"><div align=\"right\">栏目名称：</div></td>
					  <td width=\"65%\"><label>
						<input name=\"SysMenu1\" id=\"SysMenu1\" type=\"text\" size=\"30\" />
					  </label></td>
					</tr>
					<tr>
					  <td><div align=\"right\">排序：</div></td>
					  <td><label>
						<input name=\"SysMenu3\" type=\"text\" value=\"".GetMenuOrder($MenuID)."\" size=\"10\" />*请输入数字
					  </label></td>
					</tr>
					<tr>
					  <td>&nbsp;</td>
					  <td><label>
						<input type=\"submit\" name=\"Submit\" onclick=\"return yzadd()\" style=\"background-image:url(../../iamges/botton_baocun.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" />
						<input type=\"button\" name=\"Submit2\" style=\"background-image:url(../../iamges/botton_quxiao.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" onClick=\"window.history.back();\"/>
					  </label></td>
					</tr>
				  </table>
				</form>
				<script type=\"text/javascript\">
					function $(getid){return document.getElementById(getid);}
					function yzadd()
					{
						if($(\"SysMenu1\").value==\"\")
						{
							alert(\"栏目名称,不能为空！！\");
							$(\"SysMenu1\").focus();
							return false;
						}
						if($(\"SysMenu3\").value==\"\")
						{
							alert(\"排序,不能为空！！\");
							$(\"SysMenu3\").focus();
							return false;
						}
					}
				</script>";

		}
		else
		{
			$classlist=$db->getlistarr("select * from menusys where menusys8='classsys' Order by menusys0 desc");	
			$classstr='';
			foreach($classlist as $val){
				$classstr.="<option value='".$val[0]."'>".$val[1]."</option>";
			}
			
			echo "当前位置：添加二级栏目&nbsp;>&nbsp;添加栏目
				<form id=\"form1\" name=\"form1\" method=\"post\" action=\"?MenuID=$MenuID\">
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				  <input name=\"SysMenu2\" type=\"hidden\" value=\"$MenuID\" size=\"30\" />
				  <table width=\"95%\" border=\"0\" align=\"center\">
					<tr>
					  <td width=\"35%\"><div align=\"right\">栏目名称：</div></td>
					  <td width=\"65%\"><label>
						<input name=\"SysMenu1\" id=\"SysMenu1\" type=\"text\" size=\"30\" />
					  </label></td>
					</tr>
					<tr>
					  <td><div align=\"right\">栏目功能：</div></td>
					  <td>
				<label>
				<select name=\"SysMenu4\">
				  <option value=\"\"  selected>请选择...</option>\n<option value=\"#||\">为空</option>";
					$res=$db->query("select * from system");
						while($rows=$db->getarray($res))
						{
							echo "<option value=\"".$rows[2]."|".$rows[1]."|".$rows[3]."\">".$rows[1]."</option>\n";
						}
				echo "</select>
				</label>
				<a href=\"selftable.php\">自定义系统管理>></a>
				</td>
					</tr>
					<tr>
					  <td><div align=\"right\">复制样式：</div></td>
					  <td>
					<select name=\"ListMenuSys\">
						  <option value=\"\" selected=\"selected\">请选择...</option>
					</select>
				  </td>
					</tr>
					<tr>
					  <td><div align=\"right\">排序：</div></td>
					  <td><label>
						<input name=\"SysMenu3\" type=\"text\" value=\"".GetMenuOrder($MenuID)."\" size=\"10\" />*请输入数字
					  </label></td>
					</tr>
					<tr>
					  <td>&nbsp;</td>
					  <td><label>
						<input type=\"submit\" name=\"Submit\" onclick=\"return yzadd()\" style=\"background-image:url(../../iamges/botton_baocun.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" />
						<input type=\"button\" name=\"Submit2\" style=\"background-image:url(../../iamges/botton_quxiao.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" onClick=\"window.history.back();\"/>
					  </label></td>
					</tr>
				  </table>
				</form>
				<script type=\"text/javascript\">
					function $(getid){return document.getElementById(getid);}
					function yzadd()
					{
						if($(\"SysMenu1\").value==\"\")
						{
							alert(\"栏目名称,不能为空！！\");
							$(\"SysMenu1\").focus();
							return false;
						}
						if($(\"SysMenu4\").value==\"\")
						{
							alert(\"请选择功能！！\");
							$(\"SysMenu4\").focus();
							return false;
						}
						if($(\"SysMenu3\").value==\"\")
						{
							alert(\"排序,不能为空！！\");
							$(\"SysMenu3\").focus();
							return false;
						}
					}
				</script>";
		}
	}
	function updateMenu($MenuID,$type=0)
	{
		$db=new mysql();
		$row=$db->getoners("select * from menusys where menusys0=".$MenuID." limit 1");
		if($type==0)
		{
			echo "当前位置：修改顶级栏目&nbsp;>&nbsp;修改栏目
				<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				   <input name=\"SysMenu0\" type=\"hidden\"  value=\"".$row[0]."\" size=\"30\" />
				  <table width=\"95%\" border=\"0\" align=\"center\">
					<tr>
					  <td width=\"35%\"><div align=\"right\">栏目名称：</div></td>
					  <td width=\"65%\"><label>
						<input name=\"SysMenu1\" value=\"".$row[1]."\" id=\"SysMenu1\" type=\"text\" size=\"30\" />
					  </label></td>
					</tr>
					<tr>
					  <td><div align=\"right\">排序：</div></td>
					  <td><label>
						<input name=\"SysMenu3\" type=\"text\"  value=\"".$row[3]."\" size=\"10\" />*请输入数字
					  </label></td>
					</tr>
					
					<tr>
					  <td>&nbsp;</td>
					  <td><label>
						<input type=\"submit\" name=\"Submit\" onclick=\"return yzadd()\" style=\"background-image:url(../../iamges/botton_baocun.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" />
						<input type=\"button\" name=\"Submit2\" style=\"background-image:url(../../iamges/botton_quxiao.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" onClick=\"window.history.back();\"/>
					  </label></td>
					</tr>
				  </table>
				</form>
				<script type=\"text/javascript\">
					function $(getid){return document.getElementById(getid);}
					function yzadd()
					{
						if($(\"SysMenu1\").value==\"\")
						{
							alert(\"栏目名称,不能为空！！\");
							$(\"SysMenu1\").focus();
							return false;
						}
						if($(\"SysMenu3\").value==\"\")
						{
							alert(\"排序,不能为空！！\");
							$(\"SysMenu3\").focus();
							return false;
						}
					}
				</script>";
		}
		else
		{
			$classlist=$db->getlistarr("select * from menusys where menusys8='classsys' Order by menusys0 desc");	
			$classstr='';
			foreach($classlist as $val){
				$classstr.="<option value='".$val[0]."'>".$val[1]."</option>";
			}
			echo "当前位置：添加下级栏目&nbsp;>&nbsp;添加栏目
				<form id=\"form1\" name=\"form1\" method=\"post\" action=\"?MenuID=$MenuID\">
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				  <p>&nbsp;</p>
				  <input name=\"SysMenu0\" type=\"hidden\"  value=\"".$row[0]."\" size=\"30\" />
				  <table width=\"95%\" border=\"0\" align=\"center\">
					<tr>
					  <td width=\"35%\"><div align=\"right\">栏目名称：</div></td>
					  <td width=\"65%\"><label>
						<input name=\"SysMenu1\" id=\"SysMenu1\"  value=\"".$row[1]."\" type=\"text\" size=\"30\" />
					  </label></td>
					</tr>
					<tr>
					  <td><div align=\"right\">栏目功能：</div></td>
					  <td>
				<label>
				<select name=\"SysMenu4\" id=\"SysMenu4\">
				  <option value=\"\"  selected>请选择...</option>\n";
					$res=$db->query("select * from system");
						while($rows=$db->getarray($res))
						{
							echo "<option value=\"".$rows[2]."|".$rows[1]."|".$rows[3]."\">".$rows[1]."</option>\n";
						}
				echo "</select>
				<script type=\"text/javascript\">document.getElementById(\"SysMenu4\").value=\"".$row[10]."|".$row[11]."|".$row[8]."\"</script>
				</label>
				<a href=\"selftable.php\">自定义系统管理>></a>
				</td>
					</tr>
					<tr>
					  <td><div align=\"right\">复制样式：</div></td>
					  <td>
					<select name=\"ListMenuSys\">
						  <option value=\"\" selected=\"selected\">请选择...</option>
					</select>
				  </td>
					</tr>
					<tr>
					  <td><div align=\"right\">排序：</div></td>
					  <td><label>
						<input name=\"SysMenu3\" type=\"text\" value=\"".$row[3]."\" size=\"10\" />*请输入数字
					  </label></td>
					</tr>
					<tr>
					  <td width='35%'><div align='right'>静态目录：</div></td>
					  <td width='65%'><input name='SysMenu19' id='SysMenu19' value='".$row[19]."' type='text' size='30' /> 如:/news/</td>
					</tr>
					<tbody style='display:none'>
					<tr>
					  <td width='35%'><div align='right'>频道页文件：</div></td>
					  <td width='65%'><input name='SysMenu12' id='SysMenu12' value='".$row[12]."' type='text' size='30' /> 如:/api/index.php/index/news/</td>
					</tr>
					</tbody>
					<tr>
					  <td><div align='right'>单页模板：</div></td>
					  <td><input name='SysMenu13' id='SysMenu13' value='".$row[13]."' type='text' size='30' /> 如:about.html</td>
					</tr>
					<tr>
					  <td><div align='right'>按分类生成：</div></td>
					  <td><select id='htmlclass' name='htmlclass'><option value='0'>请选择</option>".$classstr."</select><script type=\"text/javascript\">document.getElementById('htmlclass').value=".$row[18].";</script></td>
					</tr>
					<tr>
					  <td><div align='right'>列表页静态规则：</div></td>
					  <td><input name='SysMenu14' id='SysMenu14' value='".$row[14]."' type='text' size='30' /> 如:/news/list".'{$cid}'."_".'{$page}'.".html</td>
					</tr>
					<tr>
					  <td><div align='right'>列表页模板：</div></td>
					  <td><input name='SysMenu15' id='SysMenu15' value='".$row[15]."' type='text' size='30' /> 如:newslist.html</td>
					</tr>
					<tr>
					  <td><div align='right'>内容页静态规则：</div></td>
					  <td><input name='SysMenu16' id='SysMenu16' value='".$row[16]."' type='text' size='30' /> 如:/news/views".'{$id}'.".html</td>
					</tr>
					<tr>
					  <td><div align='right'>内容页模板：</div></td>
					  <td><input name='SysMenu17' id='SysMenu17' value='".$row[17]."' type='text' size='30' /> 如:newsdetail.html</td>
					</tr>
					<tr>
					  <td>&nbsp;</td>
					  <td><label>
						<input type=\"submit\" name=\"Submit\" onclick=\"return yzadd()\" style=\"background-image:url(../../iamges/botton_baocun.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" />
						<input type=\"button\" name=\"Submit2\" style=\"background-image:url(../../iamges/botton_quxiao.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;\" value=\" \" onClick=\"window.history.back();\"/>
					  </label></td>
					</tr>
				  </table>
				</form>
				<script type=\"text/javascript\">
					function $(getid){return document.getElementById(getid);}
					function yzadd()
					{
						if($(\"SysMenu1\").value==\"\")
						{
							alert(\"栏目名称,不能为空！！\");
							$(\"SysMenu1\").focus();
							return false;
						}
						if($(\"SysMenu4\").value==\"\")
						{
							alert(\"请选择功能！！\");
							$(\"SysMenu4\").focus();
							return false;
						}
						if($(\"SysMenu3\").value==\"\")
						{
							alert(\"排序,不能为空！！\");
							$(\"SysMenu3\").focus();
							return false;
						}
					}
				</script>
				";
		}

	}
	function mdefaultList($list,$id,$gang,$maxgang=100,$m_count)
	{
		$db=new mysql();
		if($gang==0)
		{
			$gangstring="&nbsp;&nbsp;";
		}
		else
		{
			$gangstring='&nbsp;&nbsp;';
			for($j=1;$j<=$gang;$j++)
			{
				if($j==$gang)
				{
					//$gangstring=$gangstring."└";
					$gangstring.=" |- ";
				}
				else
				{
					//$gangstring=$gangstring."&nbsp;&nbsp;";
					$gangstring.=" | ";
				}
			}
		}
		for($i=0;$i<count($list);$i++)
		{
			if($list[$i][2]==$id)
			{
				for($j=0;$j<count($list);$j++)
				{
					if($list[$j][2]==$list[$i][0])
					{
						$ky="";
						break;
					}
					else
					{
						$ky="<a href=\"config.php?MenuID=".$list[$i][0]."\" class=\"Link12\">字段管理</a> |";
					}
				}
				if($gang==0)
				{
					echo "</table></span><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" style=\"border:#FA7F18 solid 0px; background-color:#eceee9; cursor:pointer;\"><tr class=\"YKTtr\" style=\"background:#eceee9\" Height=\"25\" >";
				}
				else
				{
					echo "<tr class=\"YKTtd\" Height=\"22\" onmouseover=\"this.className='YKTtdOnMouse'\" onmouseout=\"this.className='YKTtd'\">";
				}

				if(($gang+1)<=$maxgang)
				{
					$adddropmenu="<a href=\"addmenu.php?MenuID=".$list[$i][0]."\" class=\"Link12\">  添加下级栏目</a> |";
				}
				else
				{
					$adddropmenu="";
				}

				echo "<td width=\"10%\" align=\"center\" valign=\"middle\">".$list[$i][0]."</td>";
				
				if($gang==0){
				echo  " <td width=\"15%\" align=\"left\" valign=\"middle\" onclick=\"MenuShowdisp('MenuID_',{$m_count},{$list[$i][0]})\">　".$gangstring.$list[$i][1]."[".$list[$i][3]."]　</td>
				  <td width=\"25%\" align=\"left\" valign=\"middle\" onclick=\"MenuShowdisp('MenuID_',{$m_count},{$list[$i][0]})\">　".$list[$i][11]."</td>
				  <td width=\"25%\" align=\"left\" valign=\"middle\" onclick=\"MenuShowdisp('MenuID_',{$m_count},{$list[$i][0]})\">　".$list[$i][10]."</td>";
				}else{
					echo  " <td width=\"15%\" align=\"left\" valign=\"middle\" >　".$gangstring.$list[$i][1]."[".$list[$i][3]."]　</td>
				  <td width=\"25%\" align=\"left\" valign=\"middle\" >　".$list[$i][11]."</td>
				  <td width=\"25%\" align=\"left\" valign=\"middle\" >　".$list[$i][10]."</td>";
				}
				
				if(strtolower($list[$i][10])=="system/setsys/index.php"||strtolower($list[$i][10])=="system/adminsys/index.php"||intval($list[$i][0])===1){
					echo "<td width=\"25%\" align=\"left\" valign=\"middle\">　$adddropmenu $ky <a href=\"update.php?MenuID=".$list[$i][0]."\" class=\"Link12\">修改</a></td>
				</tr>";
				}else{
					echo "<td><div align=\"left\">　$adddropmenu $ky <a href=\"update.php?MenuID=".$list[$i][0]."\" class=\"Link12\">修改</a> | <a href=\"delete.php?MenuID=&id=".$list[$i][0]."\" onclick=\"return confirm('你确认删除 [".$list[$i][1]."] 这个栏目吗？，删除后不可恢复！！')\" class=\"Link12\">删除</a></div></td>
				</tr>";
				}
				if($gang==0){
					echo "</table><span id=\"MenuID_{$list[$i][0]}\" style=\"display:none;\"><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" style=\"cursor:pointer;\">";
				}
				$vgang=$gang+1;
				if($vgang<=$maxgang)
				{
					$this->mdefaultList($list,$list[$i][0],$vgang,$maxgang,$m_count);
				}
			}
		}
	}


	function menuindexlist()
	{
		$db=new mysql();
		echo "<a href=\"addmenu.php\" class=\"\">添加顶级栏目</a>&nbsp;&nbsp;<a href=\"selftable.php\" class=\"\">自定义系统管理</a>
		<script type=\"text/javascript\">
		function MenuShowdisp(a,b,c){
			for(var i=0;i<=b;i++){
				if(i==c){
					if(document.getElementById(a+i)!=null){
						if(document.getElementById(a+i).style.display==\"none\"){
							document.getElementById(a+i).style.display=\"\";
						}else{
							document.getElementById(a+i).style.display=\"none\";
						}
					}
				}else{
					if(document.getElementById(a+i)!=null){
						document.getElementById(a+i).style.display=\"none\";
					}
				}
			}
		}
		
		</script>
		<table width=\"100%\" align=\"Left\" border=\"0\" style=\" background-color:#616975\">
			<tr class=\"YKTtr\" Height=\"25\">
			  <th width=\"10%\" style=\"background-color:#616975; color:#ffffff\"><div align=\"center\">ID</div></th>
			  <th width=\"15%\" style=\"background-color:#616975; color:#ffffff\"><div align=\"center\">栏目名称[序号]</div></th>
			  <th width=\"25%\" style=\"background-color:#616975; color:#ffffff\"><div align=\"center\">系统名称</div></th>
			  <th width=\"25%\" style=\"background-color:#616975; color:#ffffff\"><div align=\"center\">系统入口</div></th>
			  <th  style=\"background-color:#616975; color:#ffffff\"><div align=\"center\">操作</div></th>
			</tr>
			<tr><td colspan=\"5\" align=\"center\" valign=\"top\">
				<span><table width=\"100%\" border=\"0\" cellpadding=\"0\" style=\"border:#616975 solid 1px; cursor:pointer;\">
			";
		$rest=$db->query("select * from menusys order by menusys3 asc");
		$m_count_result=$db->getoners("select * from menusys order by menusys0 desc limit 0,1");
		$m_count=$m_count_result[0];
		$Menulist=$db->GetDatalist($rest);
		$this->mdefaultList($Menulist,0,0,3,$m_count);
		echo "
		
		</td></tr></table>";
	}

}

$html=new HtmlInclude();


/**
 * 配置表单
 */
class ConfigForm {
	
	
	public $adminroot;
	function __construct()
	{
		global $wwwroots,$adminroots;
		$this->adminroot=$wwwroots.'/'.$adminroots;
	}
	
  function ConfigForm() {
	 
	//
  }

  /**
   * 文本框  1
   */
  function Textbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
  {
  	$FieldConfigNamearr=explode("|",$StrFieldConfigName);
  	if(intval($FieldConfigNamearr[4])==0)
  	{
	return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\"><input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"text\" class=\"InputNone\" value=\"".$FieldValue."\" size=\"90\" />\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span></td>\n</tr>\n";
  	}
	return null;
  }
  
  function BigUploadFilesbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID=""){
	  $FieldConfigNamearr=explode("|",$StrFieldConfigName);
		if(intval($FieldConfigNamearr[4])==0){
			if(strlen($FieldConfigNamearr[5])>0){
				$ext = explode('/',$FieldConfigNamearr[5]);
				foreach($ext as $key=>$val){
					$ext[$key] = '*.'.$val;
				}
				$ext = implode(';',$ext);
			}else{
				$ext = '*.*';
			}
		return "<tr>\n<td class=\"TdLine\" width=\"140\" valign=\"top\" style=\"line-height:45px\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\"><input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"hidden\" class=\"InputNone\" value=\"".$FieldValue."\" size=\"90\" /><iframe frameborder=\"0\" scrolling=\"no\" style=\"height:69px; width:560px; overflow:hidden;\" src=\"../menusys/bgupload.php?valid=".$FieldName."&ext=".$ext."&tips=".$FieldConfigNamearr[3]."\"></iframe>\n<span id=\"".$FieldName."_Msg\" style=\"display:none\">　".$FieldConfigNamearr[3]."</span>
		</td>\n</tr>\n";
		}
		return null;
  
  }
  
  /**
   * 下拉列表
   */
  function Listbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
  {
  	$db=new mysql();
	$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	if(intval($FieldConfigNamearr[4])==0)
	{
		$result=$db->query("select * from classsys where classSys4=".$FieldConfigNamearr[2]."");
		$list=$db->GetDatalist($result);
		$optionitem=$this->listboxsub($list,0,0);
		return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">\n<select name=\"".$FieldName."\" id=\"".$FieldName."\">\n<option value=\"0\" selected=\"selected\">请选择...</option>\n{#Class:dropdownlist:{$FieldConfigNamearr[2]}:{$FieldName}#}\n</select>\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span>\n<script type=\"text/javascript\">var dropvaluename_".$FieldName."=\"".$FieldValue."\";if(dropvaluename_".$FieldName."!=\"\"&&dropvaluename_".$FieldName."!=null){document.getElementById(\"".$FieldName."\").value=\"".$FieldValue."\";}</script></td>\n</tr>\n";
	}
	return null;
  }

  function listboxsub($list,$id,$gang){
		if(is_array($list)){
			if($gang==0){
				$gangstring="";
			}else{
				$gangstring='';
				for($j=1;$j<=$gang;$j++)
				{
					if($j==$gang)
					{
						$gangstring=$gangstring." |- ";
					}
					else
					{
						$gangstring=$gangstring." | ";
					}
				}
			}
			$optionitem='';
			for($i=0;$i<count($list);$i++)
			{
				if($list[$i][2]==$id)
				{
					$optionitem.="<option value=\"".$list[$i][0]."\">".$gangstring.$list[$i][1]."</option>\n";
					$optionitem.=$this->listboxsub($list,$list[$i][0],($gang+1));
				}
			}
			return $optionitem;
		}
  }

   /**
   * 单选按钮
   */
	function Radiobox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
	{
		$db=new mysql();
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
		if(intval($FieldConfigNamearr[4])==0)
		{
			$result=$db->query("select * from classSys where classsys4=".$FieldConfigNamearr[2]." order by classsys3 asc");
			$checkedstring="";
			$radioitem='';
			while($row=$db->getarray($result))
			{
				if($FieldValue==$row[0])
				{
					$checkedstring="checked=\"checked\"";
				}
				else
				{
					$checkedstring="";
				}
				$radioitem.="<input name=\"".$FieldName."\" ".$checkedstring." type=\"radio\" value=\"".$row[0]."\">".$row[1]."</input>";
			}
			return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">{#Class:radio:{$FieldConfigNamearr[2]}:{$FieldName}#}<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span><script type=\"text/javascript\">for(var Js_".$FieldName."=0;Js_".$FieldName."<document.getElementsByName(\"".$FieldName."\").length;Js_".$FieldName."++){if(document.getElementsByName(\"".$FieldName."\").item(Js_".$FieldName.").value==\"".$FieldValue."\"){document.getElementsByName(\"".$FieldName."\").item(Js_".$FieldName.").checked=true;}}</script></td>\n</tr>\n";
		}
		return null;
	}

	/**
   * 多选按钮
   */
	function Checkbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
	{
		$db=new mysql();
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
		if(intval($FieldConfigNamearr[4])==0)
		{
			return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">{#Class:checkbox:{$FieldConfigNamearr[2]}:{$FieldName}#}<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."<script type=\"text/javascript\">SetCheckBoxValue(\"{$FieldName}[]\",\"{$FieldValue}\")</script></span></td>\n</tr>\n";
		}
		return null;
	}

	 /**
	 *  文本域
	 */
	function TextAreabox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
	{
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
		 return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\"><textarea name=\"".$FieldName."\"  rows=\"8\" cols=\"50\" id=\"".$FieldName."\" type=\"text\" class=\"textarea\">".$FieldValue."</textarea>\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span></td>\n</tr>\n";
	  	}
		return null;
	}
	
	
	function Filesbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID=""){
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
			$FieldValuestring = '';
	  		if(!empty($FieldValue)){
	  			$FieldValuestring=" [文件地址:<a href=\"{$FieldValue}\" target=\"_blank\">".$FieldValue."</a>]";
	  		}
			//accept=".xls,l.doc,.txt,.pdf"
			
			$ext = explode('/',$FieldConfigNamearr[5]);
			foreach($ext as $key=>$val){
				$ext[$key] = '.'.$val;
			}
			$ext = implode(',',$ext);
		   return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">\n
		   <a href=\"javascript:;\" class=\"a-upload\"><input type=\"file\" accept=\"".$ext."\" name=\"".$FieldName."\">文件上传</a>\n
		   <input name=\"".$FieldName."_path\" type=\"hidden\" value=\"".$FieldValue."\" id=\"".$FieldName."\">\n
		   <span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span> ".$FieldValuestring."</td>\n</tr>\n";
	  	}
		return null;
	}

	/**
	 * 文件域
	 */
	function Filebox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID=""){
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
			$tmp = '';
			$FieldValuestring = '';
	  		if(!empty($FieldValue)){
				$tmp = '<div style="margin-bottom:5px;display:none" id="'.$FieldName.'_imgshow"></div>
				<script type="text/javascript">
				$(function(){
					var img="'.$FieldValue.'";
					if(img.length>1){
						$("#'.$FieldName.'_imgshow").html("<img src=\""+img+"\" height=\"100\" />").show();
					}	
				});
				
				</script>
				';
	  			$FieldValuestring="[图片地址:<a href=\"{$FieldValue}\" target=\"_blank\">".$FieldValue."</a>]";
	  		}	
		   return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">\n".$tmp."\n
		   <a href=\"javascript:;\" class=\"a-upload\"><input type=\"file\" accept=\".jpg,.jpeg,.png,.gif,.bmp,.webp\" name=\"".$FieldName."\">图片上传</a>\n
		   <input name=\"".$FieldName."_path\" type=\"hidden\" value=\"".$FieldValue."\" id=\"".$FieldName."\">\n
		   <span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span> ".$FieldValuestring."</td>\n</tr>\n";
	  	}
		return null;
	}

	/**
	 * 编辑器
	 */
	function Editorbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
	{
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
	  		$rstring="<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">\n";
			/*
			
			fck编辑器
			
			include_once("../fckeditor/fckeditor.php");
			$sBasePath ="../fckeditor/";
			$oFCKeditor = new FCKeditor($FieldName) ;
			$oFCKeditor->BasePath   = $sBasePath ;
			$oFCKeditor->Width ="700";
			$oFCKeditor->Height = '300';
			$oFCKeditor->ToolbarSet = 'MyStyle' ;
			$oFCKeditor->Value  = $FieldValue;
			$rstring.=$oFCKeditor->Create();
			*/
			
			
			/*
			百度 ueditor
			$rstring.='
<script type="text/plain" id="'.$FieldName.'_editor" class="myEditor">'.$FieldValue.'</script>
<script type="text/javascript">
    var editor = new baidu.editor.ui.Editor({textarea:"'.$FieldName.'"});
    editor.render("'.$FieldName.'_editor");
</script>';
   
         */
		 
		 /**
		 kindeditor
		 */
		 $rstring.='<textarea name="'.$FieldName.'" id="'.$FieldName.'_editor">'.$FieldValue.'</textarea>
<script type="text/jscript">
KindEditor.ready(function(K) {
	var editor = KindEditor.create("#'.$FieldName.'_editor",{
			 minWidth:700,
			 minHeight:300,
			 width:"90%",
			 height:500
			});
})
</script>';
			
			
			//$rstring.="<textarea id=\"".$FieldName."\" name=\"".$FieldName."\" style=\"display:none\">".$FieldValue."</textarea><input type=\"hidden\" id=\"".$FieldName."___Config\" value=\"\" style=\"display:none\" /><iframe id=\"".$FieldName."___Frame\" src=\"../fckeditor/editor/fckeditor.html?InstanceName=".$FieldName."&Toolbar=MyStyle\" width=\"100%\" height=\"350\" frameborder=\"0\" scrolling=\"no\"></iframe>";
			$rstring.="<span id=\"".$FieldName."_Msg\">".$FieldConfigNamearr[3]."</span></td>\n</tr>";
			return $rstring;
	  	}
		return null;
	}
	/**
	 * 栏目ID
	 */
	function MenuIDbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
	{
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
			return "\n<input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"hidden\" class=\"InputNone\" value=\"".$FieldValue."\"/>\n";
	  	}
		return null;
	}
	/**
	 * 审核ID
	 */
	function ShenHeIDbox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
	{
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
			return "\n<input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"hidden\" class=\"InputNone\" value=\"".$FieldValue."\"/>\n";
	  	}
		return null;
	}
	
	/**
	 * 日期框
	 */
	function DateBox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
	{
		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
			return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\"><input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"text\" class=\"InputNone\" value=\"".$FieldValue."\" size=\"90\" onclick=\"new Calendar().show(this);\" />\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span></td>\n</tr>\n";
	  	}
		return null;
	}
  /**
   * 会员ID  11
   */
  function MemberID($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
  {
  		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
  		if(intval($FieldConfigNamearr[4])==0)
  		{
			return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\"><input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"text\" class=\"InputNone\" value=\"".$FieldValue."\" size=\"90\" />\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span></td>\n</tr>\n";
  		}
		return null;
  }
  
  
  /**
   * swfupload多图片上传
   */
  function PicUploadList($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
  {
  		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0){
			$r='<input type="hidden" id="'.$FieldName.'" value="'.$FieldValue.'" name="'.$FieldName.'" />
<div style="float:left;" id="'.$FieldName.'_swfupload_selectid"></div>
<div class="swfuploadfilebox" id="'.$FieldName.'_filelist"></div>
<ul class="swfuploadimg" style="padding:0px;" id="'.$FieldName.'_imageslist"></ul>
<script type="text/javascript">
 var '.$FieldName.'_myswf = new lzsswfupload("'.$FieldName.'_swfupload_selectid","'.$FieldName.'_swfuploadid","'.$FieldName.'_filelist","'.$FieldName.'_filelistbox","'.$FieldName.'","'.$FieldName.'_imageslist");
 '.$FieldName.'_myswf.start();
 '.$FieldName.'_myswf.showimages("'.$FieldValue.'");
</script>';
		   return "<tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\" valign=\"top\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">\n".$r."\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span></td>\n</tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
	  	}
		return null;

  }
  
    /**
   * 数据唯一验证  13
   */
  function ajaxcheckfield($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
  {
  		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
  		if(intval($FieldConfigNamearr[4])==0){
			$FieldNum=explode("_",$FieldName);
			return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td class=\"TdLine\"><input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"text\" onblur=\"ajaxcheck_".$FieldName."()\" class=\"InputNone\" value=\"".$FieldValue."\" size=\"90\" />\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span>
			<script type=\"text/javascript\" src=\"".$this->adminroot."/system/menusys/script/v1.js\"></script>
			<script type='text/javascript'>
			 function ajaxcheck_{$FieldName}(){
				 var sendvalue=script.get.id('".$FieldName."').value;
				if(sendvalue!=script.get.id('".$FieldName."').defaultValue && sendvalue.length>0){	
					script.ajax.get('".$this->adminroot."/system/menusys/ajax/ajaxcheckfieldvalue.php?menuid=".$MenuID."&fieldnum=".$FieldNum[1]."&fieldnumvalue='+sendvalue,function(s){
						script.get.id('".$FieldName."_Msg').innerHTML=s;																 
					});
				}
			 }
			</script>
			</td>\n</tr>\n";
  		}
		return null;
  } 
  
  
  /**
   * swfupload多图片上传
   */
  function PicUploadList1($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
  {
  		$FieldConfigNamearr=explode("|",$StrFieldConfigName);
	  	if(intval($FieldConfigNamearr[4])==0)
	  	{
			$r='<script type="text/javascript" src="js/swf.js"></script>
					<script type="text/javascript" src="js/set.js"></script>
					<script type="text/javascript" src="js/init.js"></script>
					<input type="hidden" id="'.$FieldName.'" value="'.$FieldValue.'" name="'.$FieldName.'" />
					<div style=" width:50px; float:left;  text-align:center; border: solid 1px #7FAAFF; background-color: #C5D9FF;padding: 2px;">
						<span id="spanButtonPlaceholder" style="text-align:center"></span>
					</div>
					<span id="uploadmessage" style="color:#F00"></span>
					<div id="divFileProgressContainer" style="text-align:left"></div>
					<div id="'.$FieldName.'_imglist" style="width:100%"></div>
					 <script type="text/javascript">
						var swffieldname="'.$FieldName.'";
						var splitstring="||";
						var textsplitstring=",";
						FileProgress.prototype.setuploadfilevalue=function(value){
							var fromvalue=document.getElementById(swffieldname).value;
							if(fromvalue==""){
								document.getElementById(swffieldname).value=value+textsplitstring+""+textsplitstring+"";
							}else{
								document.getElementById(swffieldname).value=fromvalue+splitstring+value+textsplitstring+""+textsplitstring+"";
							}
							loadimglist();
						};
						function delimglist(id){
							var fromvalue=document.getElementById(swffieldname).value;
							var imglist=fromvalue.split(splitstring);
							var newfromvalue="";
							var newImg="";
							var j=0;
							for(var i=0;i<imglist.length;i++){
								var img_text=imglist[i].split(textsplitstring);
								if(typeof img_text[1]=="undefined"){img_text[1]="";}
								if(typeof img_text[2]=="undefined"){img_text[2]="";}
								if(img_text[0]!=id){
									if(newfromvalue==""){
										 newfromvalue=img_text[0]+textsplitstring+img_text[1]+textsplitstring+img_text[2];
									}else{
										 newfromvalue+=splitstring+img_text[0]+textsplitstring+img_text[1]+textsplitstring+img_text[2];
									}
								}
							}
							document.getElementById(swffieldname).value=newfromvalue;
							loadimglist();
						}
						function lefttextarea(obj){
							var lengths=100;
							if(obj.value.length>lengths){
								obj.value=obj.value.substring(0,lengths);
							}
						}
						function loadimglist(){
							var fromvalue=document.getElementById(swffieldname).value;
							var imglist=fromvalue.split(splitstring);
							var newImg="";
							if(fromvalue.length>0){
							for(var i=0;i<imglist.length;i++){
								var img_text=imglist[i].split(textsplitstring);
								if(typeof img_text[1]=="undefined"){img_text[1]="";}
								if(typeof img_text[2]=="undefined"){img_text[2]="";}
								 newImg+="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"120\"><img src=\""+img_text[0]+"\" style=\"width:100px; height:100px; padding:2px; border:#666666 solid 1px; margin:10px;float:left;\" /></td><td valign=\"top\"><br />标题：<input type=\"text\" id=\"swfimg_text"+i+"\" style=\"width:200px;\" value=\""+img_text[1]+"\"  maxlength=\"20\">20字以内<br />说明：<textarea id=\"swfimg_info"+i+"\" style=\" width:450px; height:50px;\" onkeyup=\"lefttextarea(this)\" onchange=\"lefttextarea(this)\" maxlength=\"20\">"+img_text[2]+"</textarea>100字以内<div style=\" text-align:left\"><a href=\"javascript:;\" onclick=\"swfuploadpicedit("+i+")\" style=\"color:red\">修改</a> <a href=\"javascript:;\" onclick=\"delimglist(\'"+img_text[0]+"\')\">删除</a>&nbsp;&nbsp;&nbsp;<font style=\"color:red\">*在添加或修改时一定要点击修改，不然不会保存标题或说明</font></div></td></tr></table>";
								}
							}
							document.getElementById(swffieldname+"_imglist").innerHTML=newImg;
						}
						
						function swfuploadpicedit(id){
							var fromvalue=document.getElementById(swffieldname).value;
							if(fromvalue==""){
								return false;
							}
							newImg="";
							newfromvalue="";
							var imglist=fromvalue.split(splitstring);
							for(var i=0;i<imglist.length;i++){
								var tempvalue="";
								var ttempvalue="";
								var img_text=imglist[i].split(textsplitstring);
								if(typeof img_text[1]=="undefined"){img_text[1]="";}
								tempvalue=i==id?document.getElementById("swfimg_text"+id).value:img_text[1];
								ttempvalue=i==id?document.getElementById("swfimg_info"+id).value:img_text[2];
								if(newfromvalue==""){
									 newfromvalue=img_text[0]+textsplitstring+tempvalue+textsplitstring+ttempvalue;
								}else{
									 newfromvalue+=splitstring+img_text[0]+textsplitstring+tempvalue+textsplitstring+ttempvalue;
								}								
							}
							document.getElementById(swffieldname).value=newfromvalue;
							alert("修改成功");
							loadimglist();
							
						}
						loadimglist();
					</script>';
			
		   return "<tr>\n<td class=\"TdLine\" width=\"140\" align=\"right\" valign=\"top\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\">\n".$r."\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span></td>\n</tr>\n";
	  	}
		return null;

  }
  
  
  /**
   * 系统时间  1
   */
  function SystemTimeBox($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID="")
  {
  	$FieldConfigNamearr=explode("|",$StrFieldConfigName);
  	if(intval($FieldConfigNamearr[4])==0)
  	{
	return "<tr style=\"display:none\">\n<td class=\"TdLine\" width=\"140\" align=\"right\">".$FieldConfigNamearr[0].":</td>\n<td  class=\"TdLine\"><input name=\"".$FieldName."\" id=\"".$FieldName."\" type=\"hidden\" class=\"InputNone\" value=\"".$FieldValue."\" size=\"90\" />\n<span id=\"".$FieldName."_Msg\">　".$FieldConfigNamearr[3]."</span></td>\n</tr>\n";
  	}
	return null;
  }
  

  /**
   * 根据配置来表单
   */
  function ShowConfigFrom($StrFieldConfigName,$FieldName,$FieldValue="",$MenuID)
  {
	$FieldConfigarr=explode("|",$StrFieldConfigName);
	$FieldConfigType=$FieldConfigarr[1];
	switch ($FieldConfigType) {
		case 1:  //文本框
			return $this->Textbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 2:  //下拉框
			return $this->Listbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 3:  //单选框
			return $this->Radiobox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 4:  //多选框
			return $this->Checkbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 5:  //文本域
			return $this->TextAreabox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 6:  //图片上传
			return $this->Filebox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 7:  //编辑器
			return $this->Editorbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 8:  //MenuID
			return $this->MenuIDbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 9: //审核ID
			return $this->ShenHeIDbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 10: //日期框
			return $this->DateBox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 11: //会员ID
			return $this->MemberID($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 12:  //swfupload 多图片上传
			return $this->PicUploadList($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 13:
			return $this->ajaxcheckfield($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 14:  //swfupload 多图片上传有描述
			return $this->PicUploadList1($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 15:  //swfupload 多图片上传有描述
			return $this->SystemTimeBox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;
		case 16:  //文件上传
			return $this->Filesbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;	
		case 17:  //文件上传
			return $this->BigUploadFilesbox($StrFieldConfigName,$FieldName,$FieldValue,$MenuID);
			break;	
			
		default:
			break;
	}

  }


}

$From=new ConfigForm();

/**
 * 分页函数[lzs]
 *
 * @param int $pagenum 总共记录条数
 * @param int $pagesize  每页显示多少条
 * @param string $pagename  分页参数名称
 * @param int $num 一边显示多少个
 * @return 分页字符串
 */
function YKT_Function_Page($pagenum,$pagesize,$pagename="page",$num=5){
	if(!is_numeric($pagenum)||!is_numeric($pagesize)){
		return "分页失败";
	}
	//获取总页数
	$pagecount=$pagenum/$pagesize;
	if(is_float($pagecount)){
		$pagecount=intval($pagecount)+1;
	}
	$params='';
	//处理其他参数以及获取当前页
	foreach($_GET as $key=>$value){
		if($key==$pagename){
			$pageindex=$value;
		}else{
			if(!empty($value)){
				$params.=$key."=".$value."&";
			}else{
				$params.=$key."&";
			}
		}
	}
	if(empty($pageindex)||$pageindex>$pagecount){
		$pageindex=1;
	}
	//显示分页数字
	$pages='';
	for($i=1;$i<=$pagecount;$i++){
		if($i>$pageindex-$num&&$i<$pageindex+$num){
			if($i!=$pageindex){
				$pages.="<a href=\"?".$params.$pagename."=$i\" style='color:#ffffff; text-decoration:underline'>[$i]</a> ";
			}else{
				$pages.="[$i] ";
			}
		}
	}
	if($pageindex==1||$pagecount==1){
		$vLost="第一页 上一页 ";
	}else{
		$vLost="<a href=\"?".$params.$pagename."=1\" style='color:#ffffff'>第一页</a> <a href=\"?".$params.$pagename."=".($pageindex-1)."\" style='color:#ffffff'>上一页</a> ";
	}
	if($pagecount==$pageindex){
		$vNext="下一页 最末页";
	}else{
		$vNext="<a href=\"?".$params.$pagename."=".($pageindex+1)."\" style='color:#ffffff'>下一页</a> <a href=\"?".$params.$pagename."=".$pagecount."\" style='color:#ffffff'>最末页</a>";
	}
	$R_Page_String= "共有 ".$pagecount." 页 当前第<span style=\"font-weight:bold;\"> ".$pageindex."</span> 页   ".$vLost.$pages.$vNext;
	return $R_Page_String;
}


function YKT_refresh_path($url=""){
	if(empty($url)||$url==""){
		echo "script type=\"text/javascript\">
		location.reload();
		</script>";
	}else{
		echo "<script type=\"text/javascript\">
		window.top.leftFrame.location.href=\"{$url}\"
		</script>";
	}
}

/**
 * 清除html代码 [lzs]
 */
function YKT_Function_Clearhtml($htmlstr){
	$pettern="/<.+?>|&nbsp;/";
	return preg_replace($pettern,"", $htmlstr);
}


/**
 * 获取列表权限配置
 *
 * @param unknown_type $MenuID
 * @return  数组
 */
function YKT_Menu_ShowList_Rules($MenuID){
	global $db;
	$FromSet_Config=$db->getoners("select * from menusys where menusys0={$MenuID} limit 1");
	$FromSet_Config_String=$FromSet_Config[5];
	$FromSet_Config_Stringarr=explode(",",$FromSet_Config_String);
	$FromSet_Config_Arr=explode("|",$FromSet_Config_Stringarr[1]);	
	return $FromSet_Config_Arr;
}

/**
 * 显示列表
 *
 * @param int $MenuID
 */
function YKT_Menu_ShowList($MenuID){
	global $db,$System,$base;
	$FromSet_Config=$db->getoners("select * from menusys where menusys0={$MenuID} limit 1");
	$FromSet_Config_Arr1=$FromSet_Config[4];
	$FromSet_Config_Arr2=$FromSet_Config[5];
	$MenuIDFieldID=$System->GetFormConfigMenuIDFieldID($MenuID);  //获取MenuID所在字段序号
	if(empty($MenuIDFieldID)){
		YKT_error('你还没有设置MenuID','/'.ADMINROOT.'/System/menusys/index.php');
	}
	$Cmd=isset($_GET["Cmd"])?$_GET["Cmd"]:"";
	$ID=isset($_GET["id"])?$_GET["id"]:"";
	if(strtolower($Cmd)=="shenhe" && is_numeric($ID) && is_numeric($_GET["ShenheValue"])){
		$ShenheValue=$_GET["ShenheValue"];
		Shenhe($MenuID,$ID,"{$ShenheValue}|{$_SESSION["admin"][1]}");
	}
	//获取列表
	$FromSet_Config_ShowList=explode(",",$FromSet_Config_Arr2);
	$FromSet_Config_ShowListArr=explode("|",$FromSet_Config_ShowList[0]);
	$FromSet_Config_ShowListDefault=explode(",",$FromSet_Config_Arr1);
	
	
	
	
	echo "当前位置：{$System->GetMenuSysField($System->GetMenuSysField($MenuID,2),1)} > {$System->GetMenuSysField($MenuID,1)}<br />";
	$RuleGroup=YKT_Menu_ShowList_Rules($MenuID); //获取配置

	$DataTableName=$System->GetTableName($MenuID); //获取表名
	$searchsqlwhere='';
	if(strlen($FromSet_Config_ShowList[5])>4)
	{
		echo '<br><form action="" method="get">
		<table width="98%" cellpadding="0" cellspacing="0" border="0">
		<tr>
		<input type="hidden" name="MenuID" id="MenuID" value="'.$MenuID.'">
		';
		//获取搜配置
		$searchconfig=new searchfrom();
		$search_arr=explode("|",$FromSet_Config_ShowList[5]);
		$search_arr_count=count($search_arr);
		if($search_arr_count>0){
			for($search_i=0;$search_i<$search_arr_count;$search_i++){
				$search_arr_list=explode('/',$search_arr[$search_i]);
				
				if(strval($search_arr_list[2])=='1'){
					echo $searchconfig->search1($search_arr_list[0],$DataTableName.$search_arr_list[1]);
					$reqeustsearchfrom=isset($_GET[$DataTableName.$search_arr_list[1]])?$_GET[$DataTableName.$search_arr_list[1]]:'';
					if(strlen($reqeustsearchfrom)>0){
						$searchsqlwhere.=" and locate('{$reqeustsearchfrom}',".$DataTableName.$search_arr_list[1].")>0 ";
					}
				}elseif(strval($search_arr_list[2])=='2'){
					$search_class_arr=explode("|",$FromSet_Config_ShowListDefault[$search_arr_list[1]]);
					
					echo $searchconfig->search2($search_arr_list[0],$DataTableName.$search_arr_list[1],$search_class_arr[2]);
					
					$reqeustsearchfrom=isset($_GET[$DataTableName.$search_arr_list[1]])?$_GET[$DataTableName.$search_arr_list[1]]:'';
					if(strlen($reqeustsearchfrom)>0 && strval($reqeustsearchfrom)<>"0"){
						$searchsqlwhere.=" and {$DataTableName}{$search_arr_list[1]}={$reqeustsearchfrom} ";
					}
					
				}elseif(strval($search_arr_list[2])=='3'){
					
					echo $searchconfig->search3($search_arr_list[0],$DataTableName.$search_arr_list[1]);
					$reqeustsearchfrom=isset($_GET[$DataTableName.$search_arr_list[1]])?$_GET[$DataTableName.$search_arr_list[1]]:'';
					if(strlen($reqeustsearchfrom)>0){
						$searchsqlwhere.=" and ".$DataTableName.$search_arr_list[1]."={$reqeustsearchfrom} ";
					}
					
				}elseif(strval($search_arr_list[2])=='4'){
					
					echo $searchconfig->search1($search_arr_list[0],$DataTableName.$search_arr_list[1]);
					if(strlen($reqeustsearchfrom)>0){
						$searchsqlwhere.=" and ".$DataTableName.$search_arr_list[1]."='{$reqeustsearchfrom}' ";
					}
				}elseif(strval($search_arr_list[2])=='5'){
					$search_class_arr=explode("|",$FromSet_Config_ShowListDefault[$search_arr_list[1]]);
					
					echo $searchconfig->search2($search_arr_list[0],$DataTableName.$search_arr_list[1],$search_class_arr[2]);
					
					$reqeustsearchfrom=isset($_GET[$DataTableName.$search_arr_list[1]])?$_GET[$DataTableName.$search_arr_list[1]]:'';
					if(strlen($reqeustsearchfrom)>0 && strval($reqeustsearchfrom)<>"0"){
						$searchsqlwhere.=" and FIND_IN_SET('{$reqeustsearchfrom}',{$DataTableName}{$search_arr_list[1]}) ";
					}
					
				}

				if($search_i<($search_arr_count-1)){
					if(($search_i+1) % 4==0){
						echo "</tr><tr>";
					}
				}
				
				

			} 
		}
		echo '</table><br /><div style="text-align:right;width:98%;"><input type="submit" value=" 搜索 " /></div></form>';
	}
	$RuleGroup_Add='';
	if($RuleGroup[0]==1){
			$RuleGroup_Add="<a href=\"../menusys/sys_add.php?MenuID={$MenuID}\" style=\"line-height:30px; font-size:14px;\"><strong>数据添加>></strong></a><br>";
	}
	echo "{$RuleGroup_Add}<form action=\"../menusys/sys_delete_save.php?MenuID={$MenuID}\" method=\"post\" name=\"delform\" id=\"delform\">
<table width=\"100%\" border=\"0\" class=\"YKTtable\" style=\"background-color:#ebebeb;\" cellspacing=\"1\" cellpadding=\"0\">\n<tr style=\" background-repeat:repeat-x; background-color:#6f7783; height:40px; padding-left:10px; color:#FFF\">\n";
	
	 //标题
	$colspan=1;
	$Data_ShowList_Count=count($FromSet_Config_ShowListArr);
	if($RuleGroup[3]==1){
	echo "<td width=\"50\" height=\"40\" align=\"center\" style=\"font-size:14px\"><strong>选择</strong></td>\n";
	}
	
	$orderid=0;
	$orderidtype='';
	$urlparams='';
	foreach($_GET as $key=>$value){
		if($key=='orderid'){
			$orderid=$value;
		}elseif($key=='orderidtype'){
			$orderidtype=$value;
		}else{
			if(!empty($value)){
				$urlparams.=$key."=".$value."&";
			}else{
				$urlparams.=$key."&";
			}
		}
	}
	for($i=0;$i<$Data_ShowList_Count;$i++){
		$FromSet_Config_ShowListArr_temp=explode('/',$FromSet_Config_ShowListArr[$i]);
		$FromSet_Config_ShowListDefaultArr=explode("|",$FromSet_Config_ShowListDefault[$FromSet_Config_ShowListArr_temp[0]]);
		
		if(intval($FromSet_Config_ShowListArr[$i])==intval($orderid) && isset($_GET['orderid']) && isset($_GET['orderidtype'])){
			if($orderidtype=='desc'){
				echo "<td height=\"40\" style=\"font-size:14px\" align=\"center\"><strong><a href=\"?{$urlparams}orderid={$FromSet_Config_ShowListArr[$i]}&orderidtype=asc\" style=\"color:#FFFFFF;\">{$FromSet_Config_ShowListDefaultArr[0]}</a>↓</strong></td>\n";
			}else{
				echo "<td height=\"40\" style=\"font-size:14px\" align=\"center\"><strong><a href=\"?{$urlparams}orderid={$FromSet_Config_ShowListArr[$i]}&orderidtype=desc\" style=\"color:#FFFFFF;\">{$FromSet_Config_ShowListDefaultArr[0]}</a>↑</strong></td>\n";
			}
		}else{
			echo "<td height=\"40\" style=\"font-size:14px\" align=\"center\"><strong><a href=\"?{$urlparams}orderid={$FromSet_Config_ShowListArr[$i]}&orderidtype=desc\" style=\"color:#FFFFFF;\">{$FromSet_Config_ShowListDefaultArr[0]}</a></strong></td>\n";
		}
		
		//echo "<td height=\"24\" align=\"center\"><strong>{$FromSet_Config_ShowListDefaultArr[0]}</strong></td>\n";
		
		$colspan=$colspan+1;
	}
	echo "<td width=\"140\"  height=\"40\" style=\"font-size:14px\" align=\"center\" ><strong>操作</strong></td>\n";
	echo "</tr>";

	$DataTableName=$System->GetTableName($MenuID); //获取表名
	
	
	$PageSize=intval($FromSet_Config_ShowList[2]);  
	$Data_Count=$db->getcount("select {$DataTableName}0 from {$DataTableName} where {$DataTableName}{$MenuIDFieldID}={$MenuID} {$searchsqlwhere}");
	
	$PageName="page";
	$PageIndex=isset($_GET[$PageName])?$_GET[$PageName]:"";
	$PageCount=ceil($Data_Count/$PageSize);
	if(is_float($PageCount)){
		$PageCount=intval($PageCount)+1;
	}
	if(empty($PageIndex)||!is_numeric($PageIndex)||$PageIndex>$PageCount||$PageIndex<0){
		$PageStart=0;
	}else{
		$PageStart=($PageIndex-1)*$PageSize;
	}
	$SqlLimit='';
	if($RuleGroup[5]==1){  //翻页权限
		$SqlLimit="limit {$PageStart},{$PageSize}";
	}
	
	if(isset($_GET['orderid']) && isset($_GET['orderidtype'])){
			if(intval($_GET['orderid'])==0){
				$orderby=" order by {$DataTableName}{$_GET['orderid']} {$_GET['orderidtype']}";
			}else{
				$orderby=" order by {$DataTableName}{$_GET['orderid']} {$_GET['orderidtype']},{$DataTableName}0 desc";
			}
	}else{
		$orderby=" order by {$DataTableName}0 desc";
	}
	$selectlistsql="select * from {$DataTableName} where {$DataTableName}{$MenuIDFieldID}={$MenuID} {$searchsqlwhere} {$orderby} {$SqlLimit}";
	$Data_result=$db->query($selectlistsql);
	
	if($Data_Count>0){
		while($row=$db->getarray($Data_result)){
			echo "<tr style='text-align:center'>";
			if($RuleGroup[3]==1){  //指量删除权限
				echo "<td height=\"30\" align=\"center\" style=\"background-color:#FFF;\"><input type=\"checkbox\" name=\"delcheck[]\" value=\"{$row[0]}\"/></td>\n";
			}
			
			for($i=0;$i<$Data_ShowList_Count;$i++){
				$FromSet_Config_ShowListArr_temp='';
				//分类
				$FromSet_Config_ShowListArr_temp=explode('/',$FromSet_Config_ShowListArr[$i]);
				$FromSet_Config_ShowListDefaultArr=explode("|",$FromSet_Config_ShowListDefault[$FromSet_Config_ShowListArr_temp[0]]);
				if(intval($FromSet_Config_ShowListDefaultArr[1])==2||intval($FromSet_Config_ShowListDefaultArr[1])==3||intval($FromSet_Config_ShowListDefaultArr[1])==4){
					
					$DataClassName=YKT_GetClassName($row[$FromSet_Config_ShowListArr_temp[0]]);
					if(isset($FromSet_Config_ShowListArr_temp[1])){
						echo "<td height=\"30\" style=\"background-color:#FFF;padding-left:5px;\" class=\"{$FromSet_Config_ShowListArr_temp[1]}\">{$DataClassName}</td>\n";
					}else{
						echo "<td height=\"30\" style=\"background-color:#FFF;padding-left:5px;\" class=\"center\">{$DataClassName}</td>\n";
					}
				}elseif(intval($FromSet_Config_ShowListDefaultArr[1])==9){

					$EchoShenhevalue=$row[$FromSet_Config_ShowListArr_temp[0]];
					if(!empty($EchoShenhevalue))
					{
						$EchoShenhevalue_arr=explode("|",$EchoShenhevalue);
						if($EchoShenhevalue_arr[0]==1){
							$EchoShenhe="已审核";
						}else{
							$EchoShenhe="未审核";
						}
					}else{
						$EchoShenhe="未审核";
					}
					if(isset($FromSet_Config_ShowListArr_temp[1])){
						echo "<td height=\"30\" style=\"background-color:#FFF;padding-left:5px;\" class=\"{$FromSet_Config_ShowListArr_temp[1]}\">{$EchoShenhe}</td>\n";
					}else{
						echo "<td height=\"30\" style=\"background-color:#FFF;padding-left:5px;\" class=\"center\">{$EchoShenhe}</td>\n";
					}
				}elseif(intval($FromSet_Config_ShowListDefaultArr[1])==6){
					
					
					$showimgpic=is_file(SITEROOT.$row[$FromSet_Config_ShowListArr_temp[0]])?'<img src="'.$row[$FromSet_Config_ShowListArr_temp[0]].'" onmousemove="moveimg(this,event,\'showimgdiv\')" width="150" height="100" onmouseout="outimg(\'showimgdiv\')"/>':'暂无图片';
					
					if(isset($FromSet_Config_ShowListArr_temp[1])){
						echo "<td height=\"30\" style=\"background-color:#FFF;\" class=\"{$FromSet_Config_ShowListArr_temp[1]}\">".$showimgpic."</td>\n";
					}else{
						echo "<td height=\"30\" style=\"background-color:#FFF;\" class=\"center\">".$showimgpic."</td>\n";				
					}
					
				}elseif(intval($FromSet_Config_ShowListDefaultArr[1]==15)){
					if(empty($row[$FromSet_Config_ShowListArr_temp[0]])){
						$time='';
					}else{
						$time=date('Y-m-d H:i:s',$row[$FromSet_Config_ShowListArr_temp[0]]);
					}
					if(isset($FromSet_Config_ShowListArr_temp[1])){
						echo "<td height=\"30\" style=\"background-color:#FFF;\" class=\"{$FromSet_Config_ShowListArr_temp[1]}\">".$time."</td>\n";
					}else{
						echo "<td height=\"30\" width=\"140\" style=\"background-color:#FFF;\" class=\"center\">".$time."</td>\n";				
					}
				}elseif(intval($FromSet_Config_ShowListDefaultArr[1]==10)){
					if(empty($row[$FromSet_Config_ShowListArr_temp[0]])){
						$time='';
					}else{
						$time=date('Y-m-d',$row[$FromSet_Config_ShowListArr_temp[0]]);
					}
					if(isset($FromSet_Config_ShowListArr_temp[1])){
						echo "<td height=\"30\" style=\"background-color:#FFF;\" class=\"{$FromSet_Config_ShowListArr_temp[1]}\">".$time."</td>\n";
					}else{
						echo "<td height=\"30\" width=\"140\" style=\"background-color:#FFF;\" class=\"center\">".$time."</td>\n";				
					}
				}elseif(intval($FromSet_Config_ShowListArr_temp[0]==0)){
					if(isset($FromSet_Config_ShowListArr_temp[1])){
						echo "<td height=\"30\" style=\"background-color:#FFF;padding-left:5px;\" class=\"{$FromSet_Config_ShowListArr_temp[1]}\">{$row[$FromSet_Config_ShowListArr_temp[0]]}</td>\n";
					}else{
						echo "<td height=\"30\" width=\"70\" style=\"background-color:#FFF;padding-left:5px;\" class=\"center\">{$row[$FromSet_Config_ShowListArr_temp[0]]}</td>\n";				
					}
				}else{
					
					if(isset($FromSet_Config_ShowListArr_temp[1])){
						echo "<td height=\"30\" style=\"background-color:#FFF;padding-left:5px;\" class=\"{$FromSet_Config_ShowListArr_temp[1]}\">{$row[$FromSet_Config_ShowListArr_temp[0]]}</td>\n";
					}else{
						echo "<td height=\"30\" style=\"background-color:#FFF;padding-left:5px;\" class=\"center\">{$row[$FromSet_Config_ShowListArr_temp[0]]}</td>\n";				
					}
				}
			}
			$RuleGroup_edit = '';
			if($RuleGroup[1]==1){  //修改权限
				
					$RuleGroup_edit="<a href=\"../menusys/sys_update.php?MenuID={$MenuID}&id={$row[0]}\">修改</a>";
			}
			$RuleGroup_del='';
			if($RuleGroup[2]==1){  //删除权限
				$RuleGroup_del="<a href=\"../menusys/sys_delete.php?MenuID={$MenuID}&id={$row[0]}\" onclick=\"return confirm('你确认要删除吗？,删除后不能恢复！！')\">删除</a>";
			}
			
			$RuleGroup_ShenHe="";
			if($RuleGroup[4]==1 && $System->GetFormConfigShenHeIDFieldID($MenuID)!==false){  //审核权限
				
				$EchoShenhelink=$row[$System->GetFormConfigShenHeIDFieldID($MenuID)];
				
					if(!empty($EchoShenhelink))
					{
						$EchoShenhelink_arr=explode("|",$EchoShenhelink);
						if($EchoShenhelink_arr[0]==1){
							$RuleGroup_ShenHe="<a href=\"?MenuID={$MenuID}&Cmd=shenhe&ShenheValue=0&id={$row[0]}\">取消审核</a>";
						}else{
							$RuleGroup_ShenHe="<a href=\"?MenuID={$MenuID}&Cmd=shenhe&ShenheValue=1&id={$row[0]}\">我要审核</a>";
						}
					}else{
						$RuleGroup_ShenHe="<a href=\"?MenuID={$MenuID}&Cmd=shenhe&ShenheValue=1&id={$row[0]}\">我要审核</a>";	
					}
						
			}
			$send62='';
			if($MenuID==62){
				//$send62="<a href=\"diy.php?id={$row[0]}\" >生成广告代码</a>";
			}
			if(!empty($row[2])){
				$htmldisplay='<a href="'.$row[2].'" target="_blank">查看</a>';
			}else{
				$htmldisplay='';
			}
			echo "<td width=\"140\" style=\"background-color:#FFF\" height=\"30\" align=\"center\">{$htmldisplay} {$RuleGroup_edit} {$RuleGroup_del} {$RuleGroup_ShenHe} {$send62}</td>\n";
			echo "</tr>";
		}
	}else{
		echo "<tr><td style=\"background-color:#FFF\" height=\"40\" colspan=\"{$colspan}\" align=\"center\">暂无相关数据...</td></tr>\n";
	}
	echo "</table>\n";
	$RuleGroup_Page='';
	if($RuleGroup[5]==1){  //翻页权限
		$RuleGroup_Page=YKT_Function_Page($Data_Count,$PageSize,$PageName,5);
	}
	$RuleGroup_alldel='';
	if($RuleGroup[3]==1){
		$RuleGroup_alldel="<input name=\"chkAll\" type=\"checkbox\" onclick=\"CheckAll()\" value=\"checkbox\"  style=\"border:1px;\" />&nbsp;&nbsp;<input name=\"submit\" type='submit' onClick=\"return confirm('你确认要删选中的记录吗？')\" value='删除' style=\"  padding: 4px 10px;\" /><input name=\"Action\" type=\"hidden\" id=\"Action\" value=\"Del\" />";
	}
	echo "<table width=\"100%\" border=\"0\" style=\" font-size:14px; background-color:#6f7783;  color:#FFF\" cellpadding=\"0\"><tr><td align=\"center\" height=\"40\" width=\"100\" valign=\"middle\">{$RuleGroup_alldel}</td><td align=\"center\" class=\"page\" style=\" font-size:14px;\">{$RuleGroup_Page}</td></tr></table>
	</form>
	<script type=\"text/javascript\">
		function CheckAll(obj){
			var delcheck=document.getElementsByName(\"delcheck[]\");
			var t=document.getElementsByName(\"chkAll\");
			if(t.checked){
				for(var i=0;i<delcheck.length;i++){
						delcheck.item(i).checked=false;
				}
				t.checked=false;
			}else{
				for(var i=0;i<delcheck.length;i++){
						delcheck.item(i).checked=true;
				}
				t.checked=true;
			}
		}
	</script>
	";
	
	echo '<script type="text/javascript">
function moveimg(t,event,id){
	var img = document.getElementById(id);
	img.style.display="";
	img.innerHTML="<img src=\""+t.src+"\" width=\"250\" />";
	if(document.body.scrollTop){
		img.style.left=(document.body.scrollLeft+event.clientX+12)+"px";
		img.style.top=(document.body.scrollTop+event.clientY+12)+"px";
	}else{
		img.style.left=(document.documentElement.scrollLeft+event.clientX+12)+"px";
		img.style.top=(document.documentElement.scrollTop+event.clientY+12)+"px";
	}
}
function outimg(id){
	var img = document.getElementById(id);
	img.style.display="none";
}
</script>
<div style="border: solid 1px #ccc; z-index:100; display:none; position:absolute;" id="showimgdiv"></div>';

$iscreatehtmlfield = array(
	$FromSet_Config['menusys12'],
	$FromSet_Config['menusys20'],
	$FromSet_Config['mmenusys12'],
	$FromSet_Config['mmenusys20'],
	
	//$FromSet_Config['menusys18'],
	
	$FromSet_Config['menusys14'],
	$FromSet_Config['menusys15'],
	$FromSet_Config['mmenusys14'],
	$FromSet_Config['mmenusys15'],
	
	$FromSet_Config['menusys16'],
	$FromSet_Config['menusys17'],
	$FromSet_Config['mmenusys16'],
	$FromSet_Config['mmenusys17'],
);
foreach($iscreatehtmlfield as $val){
	if(strlen($val)>0){
		echo '<br /><input type="button" onclick="window.location.href=\'../htmlSys/onekeyall.php?menuid='.$MenuID.'\'" value="更新静态页" />';
		break;
	}
}

	
}


/**
 * 获取指定的分类名称
 *
 * @param int $ClassID
 * @return 分类名称
 */
function YKT_GetClassName($ClassID){
	global $db;
	static $func_YKT_GetClassName = array();
	if(!isset($func_YKT_GetClassName[$ClassID])){
		if(!empty($ClassID)&&$ClassID!=""&&is_numeric($ClassID)){
			if(strpos($ClassID,",")===false){
				$Data_Arr=$db->getoners("select * from classsys where classSys0={$ClassID} limit 1");
				$R_String=$Data_Arr[1];
			}else{
				$ClassID_Arr=explode(",",$ClassID);
				for($i=0;$i<count($ClassID_Arr);$i++){
					$Data_Arr=$db->getoners("select * from classsys where classsys0={$ClassID_Arr[$i]} limit 1");
					$R_String.=$Data_Arr[1];
					if($i<count($ClassID_Arr)-1){
						$R_String.="、";
					}
				}
				
			}
		}else{
			$R_String="";
		}
		$func_YKT_GetClassName[$ClassID] = $R_String;
	}
	return $func_YKT_GetClassName[$ClassID];
} 

/**
 * 计算权限
 * 
 * @param int $IntRuleValue
 * @param int $StepNum
 * @return 权限字符串
 */
function GetRule($IntRuleValue,$StepNum){
	if(is_numeric($IntRuleValue)){
		return strrev(str_pad(decbin($IntRuleValue),$StepNum,'0',STR_PAD_LEFT));
	}
}

function isGetRule($MenuID,$UserID,$num){
	global $db;
	$r='0';
	if(is_numeric($MenuID)){
		$sql="select menusys7 from menusys where menusys0={$MenuID} limit 1";
		$dataarr=$db->getoners($sql);
		if(is_array($dataarr)){
			$RuleGroup=$dataarr[0];
			if(strpos($RuleGroup,",")===false){
				$MenuRule_arr=explode("|",$RuleGroup);
				if($MenuRule_arr[0]==$UserID){
					$Rulestr=GetRule($MenuRule_arr[1],5);
					$r=$Rulestr{($num-1)};
				}else{
					$r='0';
				}
			}else{
				
				$RuleGrouparr=explode(",",$RuleGroup);	
				$RuleGroupcount=count($RuleGrouparr);

				for($i=0;$i<$RuleGroupcount;$i++){
					$MenuRule_arr=explode("|",$RuleGrouparr[$i]);
					
					if($MenuRule_arr[0]==$UserID){
						$Rulestr=GetRule($MenuRule_arr[1],5);
						$r=$Rulestr{($num-1)};
					}
				}
			}
		}
	}
	return $r;
}






//执行审核
function Shenhe($MenuID,$ID,$ShValue){
	global $db,$System,$base;
	//获取审核ID字段号
	$ShenHe_FidleNum=$System->GetFormConfigShenHeIDFieldID($MenuID);
	//获取表名
	$ShenHe_TableName=$System->GetTableName($MenuID);
	$ShenHe_SQL="update {$ShenHe_TableName} set {$ShenHe_TableName}{$ShenHe_FidleNum}='{$ShValue}' where {$ShenHe_TableName}0={$ID} limit 1";
	$db->exec($ShenHe_SQL);
}

//获取栏目排序
function GetMenuOrder($MenuID=0){
	global $db;
	$SQLstring="select menusys3 from menusys where menusys2='{$MenuID}' order by menusys3 desc limit 1";
	$Data_result=$db->getoners($SQLstring);
	$R_string=$Data_result[0]+1;
	return $R_string;
}

function GetClassOrder($MenuID,$SuperiorID){
	global $db,$System;
	$Get_FieldNum=$System->GetFormConfigMenuIDFieldID($MenuID);
	$SQLstring="select classsys3 from classsys where classsys2='{$SuperiorID}' and classsys{$Get_FieldNum}={$MenuID} order by classsys3 desc limit 1";
	$Data_result=$db->getoners($SQLstring);
	$R_string=$Data_result[0]+1;
	return $R_string;
}










class searchfrom
{
	function search1($searchname,$searchid){
		$r_string='<td style="text-align:right;padding-right:10px;">'.$searchname.'：</td><td><input type="text" name="'.$searchid.'" id="'.$searchid.'" style="width:120px;" /></td>';
		return $r_string;
	}
	
	function search2($searchname,$searchid,$classmenuid){
		global $db;
		$result=$db->query("select * from classsys where classsys4={$classmenuid}");
		$list=$db->GetDatalist($result);
		$optionitem=$this->dropdownlist($list,0,0);
		echo "<td style=\"text-align:right;padding-right:10px;\">"."{$searchname}：</td><td><select name=\"{$searchid}\" id=\"{$searchid}\">\n<option value=\"0\" selected=\"selected\">请选择...</option>\n{$optionitem}\n</select>"."</td>";
	}
	
	function search3($searchname,$searchid){
		$r_string='<td style="text-align:right;padding-right:10px;">'.$searchname.'：</td><td><input type="text" name="'.$searchid.'" id="'.$searchid.'" style=" border:#1A9BF7 solid 1px;width:120px;"  /></td>';
		return $r_string;
	}
	
	
	function dropdownlist($list,$id,$gang)
	  {
		  $gangstring='';
		if(is_array($list))
		{
			
			if($gang==0)
			{
				$gangstring="";
			}
			else
			{
				
				for($j=1;$j<=$gang;$j++)
				{
					if($j==$gang)
					{
						$gangstring=$gangstring." |- ";
					}
					else
					{
						$gangstring=$gangstring." | ";
					}
				}
			}
			$optionitem='';
			for($i=0;$i<count($list);$i++)
			{
				if($list[$i][2]==$id)
				{
					$optionitem.="<option value=\"".$list[$i][0]."\">".$gangstring.$list[$i][1]."</option>\n";
					$optionitem.=$this->dropdownlist($list,$list[$i][0],($gang+1));
				}
			}
			return $optionitem;
		}
	  }
}


//获取读出分类
function getclasslistarray($classid,$sqlwhere=''){
	global $db;
	$db=is_object($db)?$db:new mysql();
	$r=array();
	if(!is_numeric($classid)){
		return $r;
	}
	$r=$db->getlistarr('select classsys0,classsys1,classsys2 from classsys where classsys4='.$classid.' '.$sqlwhere);
	return $r;
}

